package com.mijie.fentsi;


import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import net.sf.json.JSONArray;

import org.jf.smali.smaliParser.line_directive_return;


import com.caucho.json.JsonArray;
import com.mijie.dweiuPkg.dweiuMatchController;
import com.mijie.homi.search.util.AppendFile;
import com.mijie.homi.search.util.DbNdsController;
import com.mijie.homi.search.util.Dbcontroller;
import com.mijie.homi.search.util.god;
import com.mijie.homi.search.util.listUtil;
import com.mijie.homi.search.util.strUtil;
import com.mijie.homi.search.util.timeTester;
import com.mijie.query.fulltxtControllor;

//import com.sun.xml.internal.ws.wsdl.writer.document.Types;

public class renvaEventC extends fulltxtControllor {

	public static timeTester t1;

	public static void main(String[] args) {
		// String s = "C:\\renvaEvent\\renvagwesyi.txt";
		// String str =
		// "一个|男的|跟|一个|女的|在一起|一年|多|男的|对|女的|很好|要|什么都|给他|买|为什么|那个|女的|要|提出|分手|男的|也没|有|在|外面|瞎搞|";
		// // str =
		// //
		// "想要|喜欢|一个人|想|有一个|喜欢的|人|感觉|自己|很难|真正|喜欢|一个人|更|何况|是|爱上|一个人|了|我|到底|怎么了|该|怎么办|";
		// // str="我|新闻|香|识|女人|";
		// // str = "起床|咯|每天|早上|有|饭|吃|真好|";
		// // str = "不敢|接|妈妈|电话|就|怕|她|提|成绩|的|事|烦|哪|";
		// String s3 =
		// "[因为, 无意, 没接, 到, 你的, 电话, 从, 凌晨, 等到, 你, 上班, 的, 时间, 才, 给你, 打电话, 你, 却, 因为, 睡觉, 说,"
		// +
		// " 我, 烦, 等到, 你, 我都, 下班了, 给你, 打电话, 你, 因为, 你在, 吃饭, 说, 等, 会, 儿, 打, 结果, 这, 一等, 就是, 4, 个, 多, 小时,"
		// +
		// " 我, 承认, 我, 很, 不开心, 很, 不开心, 看了看, 日期, 突然, 想起, 你说, 的, 今天晚上, 要, 陪, 你, 爸, 妈, 去, 唱歌,"
		// +
		// " 我, 承认, 我, 伤心, 了, 真的, 伤心, 了, 你, 还是, 那么, 喜欢, 玩, 可以, 因为, 去, 玩, 而, 忘记, 我的, 存在,"
		// +
		// " 这, 就, 是我, 死心塌地, 爱, 着, 的, 男人, 这, 就, 是我, 一心一意, 对待, 的, 男人, 这, 就, 是我, 执意, 叛逆, 选择, 的, 男人,"
		// +
		// " 我, 累了, 不论, 对, 谁, 我都, 累了, 在, 我的, 世界, 里, 没有, 所谓, 长久, 的, 情, 不管, 是这个, 世间, 的, 哪, 一种, 情]";
		// s3 = s3.replaceAll(",", "\\|");
		// s3 = s3.replaceAll(" ", "");
		// str = s3;
		// str =
		// "男人|最|霸气|的|地方|就|在于|我|媳妇|脾气|不好|我|惯|的|我|媳妇|胖|我喜欢|我|媳妇|没|钱|我|养|她|关键|是我|爱她|"
		// +
		// "郑|海潮|说|聪明的|男人|会|把|自己的|女人|宠|得|无法无天|让|别的|男人|都|接受|不了|只有|傻|男人|才会|让|自己的|女人|受尽|委屈|"
		// + "最终|变成|别的|男人|手心|中的|宝|";
		// renvaEventC rc = new renvaEventC();
		// String type = rc.getType(str, s);
		// String rcak = JSONArray.fromObject(rc.TypeResult).toString();
		// System.out.println("--type:" + rcak);
		//
		// System.out.println("-start to get evetn ");
		// String eventwordlib = "c:\\renvaEvent\\eventkeyword.txt";
		// String[] sa = str.split("\\|");
		// String evetn = "";//
		// // List liEvent = rc.getEvents(sa, rc.TypeResult, eventwordlib);
		// //
		// // String r = JSONArray.fromObject(liEvent).toString();
		// // System.out.println(r);
		// // // Map map2 = cacheSourceLineAndWordArray(li);
		// // String evetn=rc.getEvent(str,type,eventwordlib);
		//
		// // System.out.println("--evetn:" + evetn);
		//

		timeTester t = new timeTester(" ca");
		// t1 = t;
		//
		// String sourcefile = "  C:\\sincin\\sincin_fentsi.txt";
		// String target = "C:\\sincin\\sincin_fentsi_cate.txt";
		// String eventWordlib = eventwordlib;
		// String typeWordLib = s;
		// // getTypeAndEvent(sourcefile, target, typeWordLib, eventWordlib);
		//		
		renvaEventC rec = new renvaEventC();
		// String sca29= rec.conventProblemType2sincinRenvaRelation("亲子教育");
		// System.out.println(sca29);

		// List liEvent_cb3 = rec.getEventsFromDbCb3();
		// String r = JSONArray.fromObject(liEvent_cb3).toString(2);

		// cb3pm
		// testgeneRenvaList4problemlib();
		// System.out.println(r);

		// cb5
		// test_getEventFromDweiuLib();

		// getRenvasByKWnDweiuNKW2_test();
		getTypeFromDB_test();
		t.printUseTime();

	}

	private static void testgeneRenvaList4problemlib() {
		renvaEventC rec = new renvaEventC();
		rec.iniTypeKeywordLibFromDB();
		Map mp = new HashMap<String, String>();
		String str = "我想在学校签份工作怎么这么难，为什么大多单位不要女的。";
		mp.put("content", str);

		boolean b = strUtil.isFind(str, "单位*女的");
		System.out.println("xx" + b);

		List li = rec.geneRenvaList4problemlib("1,12", mp);

		String r = JSONArray.fromObject(li).toString(2);
		System.out.println(r);

	}

	public static Map mp4event_key_is_ByaohaoAndEventname_value_is_keywordSet;

	public List getEvents(String[] str, List<Map> typeResult2,
			String eventwordlib) {
		iniEventKeywordlib(eventwordlib);

		// if (true)
		// return null;

		return getEvents(str, typeResult2);
	}

	@SuppressWarnings("unchecked")
	private List getEvents(String[] str_arrfmt, List<Map> typeResult2) {
		List li_r = new ArrayList();

		// for (Map typeresult : typeResult2) { //cb5 no syonhwe

		// String renvaRelation = (String) typeresult.get("name");
		String renvaRelation = "";
		List<Map> events = getEventsFromOneRenvaRelation(str_arrfmt,
				renvaRelation, this.oritxt);
		// Map event_mapfmt = getEvent(str, type,"");
		// li_r.add(event_mapfmt);
		li_r.addAll(events);

		// }

		// if(li_r.size()==0)
		// {
		// for(Map typeresult:typeResult2)
		// {
		// String type=(String) typeresult.get("name");
		// Map mp = new HashMap<String, Object>();
		// mp.put("num", 0);
		// mp.put("event",type+"_其他");
		// li_r.add(mp);
		// }
		// }
		return li_r;
	}

	/**
	 * cb5 for single renva multi events By kw and Dweiu
	 * 
	 * @param strArrfmt
	 * @param renvaRelationSingle
	 * @return
	 */
	public List<Map> getEventsFromOneRenvaRelation(String[] str_arrfmt,
			String renvaRelation, String str4dweiuMatch) {
		String type = conventProblemType2sincinRenvaRelation(renvaRelation);

		List li_r = new ArrayList();
		// Map<String, Set> lineses = (Map)
		// mp4event_key_is_ByaohaoAndEventname_value_is_keywordSet.get(type);
		Map<String, Set> lineses = mp4event_key_is_ByaohaoAndEventname_value_is_keywordSet;
		for (Map.Entry<String, Set> entry : lineses.entrySet()) {
			// System.out.println("key= " + entry.getKey() + " and value= " +
			// entry.getValue());

			Set set = entry.getValue();
			int chwsyeNum = chwsyeNum(str_arrfmt, set); // %54
			if (chwsyeNum > 0) {
				Map mp = new HashMap<String, Object>();
				mp.put("num", chwsyeNum);
				mp.put("event", entry.getKey());
				li_r.add(mp);
			}
		}

		// cb9 dweiu KW pinsin ..ywelaish ydiyda ..
		Set setx = listUtil.toSet(li_r, "event");
		if(1==2)
		{
	 	String event = getEventFromDweiuLib(str4dweiuMatch, renvaRelation);
		}
		dweiuMatchController dmc = new dweiuMatchController();
		List<String> events_from_dweiu=dmc.getEventsFromDweiuLib(str4dweiuMatch);
		List<String> l2=dmc.removeAllExistEvent(events_from_dweiu, setx);
		for(String eventx:l2) {
				Map mp = new HashMap<String, String>();
				mp.put("num", "0");
				mp.put("event", eventx);
				mp.put("by", "dweiu");
				li_r.add(mp);

			}
		// //

		// /////if none other
		if (li_r.size() == 0) {

			// if(event==null)
			// {
			Map mp = new HashMap<String, Object>();
			mp.put("num", 0);
			mp.put("event", type + "_其他");
			li_r.add(mp);
			return li_r;
			// }else
			// {
			// Map mp = new HashMap<String, Object>();
			// mp.put("num", 0);
			// mp.put("parseBy", "dweiu");
			// mp.put("event", event);
			// li_r.add(mp);
			// return li_r;
			// }
		} else
			return li_r;
	}

	static void test_getEventFromDweiuLib() {
		String str4dweiuMatch = "伤心@想有个女闺蜜，很好很好的闺蜜，对我好，我也对她好的那种，很渴望有这么一个人";
		renvaEventC rec = new renvaEventC();
		rec.iniEventKeywordlibFromdb();
		String r = rec.getEventFromDweiuLib(str4dweiuMatch, "朋友关系");
		System.out.println(r);
	}

	/**
	 * 
	 * @param str4dweiuMatch
	 * @param renvaRelation
	 * @return evetn_fullFromat
	 */
	private String getEventFromDweiuLib(String str4dweiuMatch,
			String renvaRelation) {
		Set<String> key = map4eventDweiu.keySet();
		for (Iterator it = key.iterator(); it.hasNext();) {
			String event = (String) it.next();
			;
			List<String> dweius = (List) map4eventDweiu.get(event);
			for (String dweiu : dweius) {
				boolean rs = strUtil.isFind(str4dweiuMatch, dweiu);
				if (rs) {
					// +renvaRelation+"_"
					String byaohao = (String) map4eventByaohaoComparetable
							.get(event);
					String event_fullFormat = byaohao + "_" + event;
					// System.out.println("event:"+event);
					return event_fullFormat;
				}
			}
		}

		return null;

	}

	private List getEvents_AndByDweiu(String[] str, List<Map> typeResult2,
			String str_strfmt) {
		List li_r = new ArrayList();

		for (Map typeresult : typeResult2) {
			String type = (String) typeresult.get("name");
			Map event_mapfmt = getEvent(str, type, str_strfmt);
			li_r.add(event_mapfmt);

		}

		return li_r;
	}

	/**
	 * 
	 * @param str_arrfmt
	 * @param typeca29
	 * @param str_cb3
	 * @return
	 */
	private Map getEvent(String[] str_arrfmt, String typeca29, String str_cb3) {
		String type = conventProblemType2sincinRenvaRelation(typeca29);

		List li_r = new ArrayList();
		Map<String, Set> lineses = (Map) mp4typeAndEventfileLinesetX.get(type);
		for (Map.Entry<String, Set> entry : lineses.entrySet()) {
			// System.out.println("key= " + entry.getKey() + " and value= " +
			// entry.getValue());

			Set set = entry.getValue();
			int chwsyeNum = chwsyeNum(str_arrfmt, set); // %54
			if (chwsyeNum > 0) {
				Map mp = new HashMap<String, Object>();
				mp.put("num", chwsyeNum);
				mp.put("event", entry.getKey());
				li_r.add(mp);
			}
		}

		if (li_r.size() == 0) {

			String event = getEventFromDweiuLib(str_cb3);
			if (event == null) {
				Map mp = new HashMap<String, Object>();
				mp.put("num", 0);
				mp.put("event", type + "_其他");
				return mp;
			} else {
				Map mp = new HashMap<String, Object>();
				mp.put("num", 0);
				mp.put("parseBy", "dweiu");
				mp.put("event", type + "_" + event);
				return mp;
			}
		} else
			return (Map) li_r.get(0);
	}

	// private String getEventFromDweiuLib(String strCb3) {
	// // TODO Auto-generated method stub
	// return null;
	// }

	private String getEventFromDweiuLib(String strCb3) {
		// TODO Auto-generated method stub
		return null;
	}

	Map mp4conventProblemType2sincinRenvaRelation;

	/**
	 * cb3 adjust
	 * 
	 * @param ProblemType_hezifmt
	 * @return
	 */
	public String conventProblemType2sincinRenvaRelation(
			String ProblemType_hezifmt) {
		// 恋爱男女 夫妻关系 婆媳关系 长辈关系 孩子教育 领导关系 同事关系 客户关系 师长关系 舍友关系 同学关系 朋友关系 兄弟姐妹
		String s = " |家庭矛盾>夫妻关系 |长辈代沟>长辈关系|亲子教育>孩子教育| 事业前途>自身烦恼|职场烦恼>自身烦恼| 社会热点>自身烦恼 |学习烦恼>自身烦恼";
		if (mp4conventProblemType2sincinRenvaRelation == null) {
			mp4conventProblemType2sincinRenvaRelation = new HashMap<String, String>();
			String[] a = s.split("\\|");
			for (String type1Andtype2 : a) {
				if (type1Andtype2.trim().length() == 0)
					continue;
				type1Andtype2 = type1Andtype2.trim();
				String[] a2 = type1Andtype2.split(">");
				String type4prob = a2[0];
				String sincinType = a2[1];
				mp4conventProblemType2sincinRenvaRelation.put(type4prob,
						sincinType);
			}

		}
		String sincinRenva = (String) mp4conventProblemType2sincinRenvaRelation
				.get(ProblemType_hezifmt);
		if (sincinRenva == null || sincinRenva.equals(""))
			return ProblemType_hezifmt;
		else
			return sincinRenva;
	}

	private String getEvent(String str, String type, String eventwordlib) {
		List<String> li_r = getEventList(str, type, eventwordlib);
		// li_r = getEventListFiltother(li_r, type);
		if (li_r.size() == 0)
			return type + "_其他";
		return listUtil.toString(li_r, " | ");
	}

	/**
	 * * [0010001_恋爱男女_追求,3 0100004_自身烦恼_恋爱,3]
	 * 
	 * @param liR
	 * @param type
	 * @return
	 */
	private List<String> getEventListFiltother(List<String> liR, String type) {

		List<String> li_r = new ArrayList<String>();
		for (String event : liR) {
			if (event.contains(type))
				li_r.add(event);
		}
		return li_r;
	}

	static Map fileLineMap; // map(line, {word,word2})

	/**
	 * --type:[{"num":1,"name":"长辈关系"},{"num":1,"name":"学习烦恼"}] -start to get
	 * evetn
	 * [{"num":1,"event":"0040001_长辈关系_学习"},{"num":1,"event":"0070001_学习烦恼_成绩"}]
	 * 
	 * @param sourcefile
	 * @param target
	 * @param typeWordLib
	 * @param eventWordlib
	 */
	private static void getTypeAndEvent(String sourcefile, String target,
			String typeWordLib, String eventWordlib) {

		sourcefile = sourcefile.trim();
		listUtil lic = new listUtil();
		List<String> li = lic.fileRead2list(sourcefile);

		List<String> li_r = new ArrayList<String>();

		renvaEventC rc = new renvaEventC();
		rc.cacheSourceLineAndWordArrayX(li);
		t1.printUseTime(); // 1.2s
		// if(true)
		// return;

		int n = 0;
		for (String[] line : rc.li4readSource) {
			n++;
			if (n % 300 == 0)
				System.out.println("---getTypeAndEvent:" + n);
			if (line.length < 7) {
				continue;
			}

			String[] words = line;
			String type = rc.getType(words, typeWordLib);
			List event = rc.getEvents(line, rc.TypeResult, eventWordlib);
			String eventStrformat = JSONArray.fromObject(event).toString();
			type = JSONArray.fromObject(rc.TypeResult).toString();
			String s = Arrays.toString(line) + "\r\ntype:" + type
					+ "\r\nevent:" + eventStrformat + "\r\n---------------";
			li_r.add(s);

			if (n % 5000 == 0) {
				listUtil lu = new listUtil();
				String conent = lu.List2String(li_r);
				AppendFile.method1(target, conent);
			}
		}

		// System.out.println("--fini:" + map2.size());
		lic.saveList2file(li_r, target);

	}

	public static Map<String, Set> index4typeTsikuFile;
	public List<Map> TypeResult = new ArrayList<Map>();
	private static Map<String, Set> KWlev2_map = new HashMap<String, Set>();;

	@SuppressWarnings("unchecked")
	private String getType(String[] words, String typeWordLib) {

		iniTypeKeywordLib(typeWordLib);
		return getTypeCa25(words);

	}

	/**
	 * ger ren va KW only <br>
	 * h
	 * 
	 * @history change cbb,add arjy kw
	 * @param words_arr
	 * @return TypeResult (list),xx
	 */
	@SuppressWarnings("unchecked")
	private String getTypeCa25(String[] words) {
		List<String> li = li4readTypeWordLib;

		String[] a = words;
		List li_r = new ArrayList();

		for (Map.Entry<String, Set> entry : index4typeTsikuFile.entrySet()) {
			// System.out.println("key= " + entry.getKey() + " and value= " +
			// entry.getValue());
			Set typeStr = entry.getValue();

			int chwsyeNum = chwsyeNum(words, typeStr);

			// String setStr = JSONArray.fromObject(typeStr).toString();
			// System.out.println("-set:" + chwsyeNum + setStr);

			if (chwsyeNum > 0) {
				Map mp = new HashMap<String, Integer>();
				// msgTypeResult r=new msgTypeResult();
				// r.type= entry.getKey();
				// r.num=chwsyeNum;
				String type = entry.getKey();
				mp.put("name", type);
				mp.put("num", chwsyeNum);
				// listUtil.isContain(word,li);
				// li_r.add(mp);
				li_r.add(mp);
			}

		}

		if (li_r.size() == 0) {
			msgTypeResult r = new msgTypeResult();
			r.type = "自身烦恼";
			r.num = 0;
			Map mp = new HashMap<String, Integer>();
			mp.put("name", "自身烦恼");
			mp.put("num", 0);
			li_r.add(mp);
		}
		// Gson gson = new Gson();
		// String reslut = gson.toJson(list);
		String s = "";// JSONArray.fromObject(li_r).toString();
		// s=JSONArray.fromObject(li_r).toString();
		// if (li_r.size() == 1) {
		// Map mpx = li_r.get(0);
		//
		// // Set set= mpx.keySet();
		// Set<String> set = mpx.keySet();
		// Iterator<String> it = set.iterator();
		// while (it.hasNext()) {
		// String strx = it.next();
		// return strx;
		// }
		//
		// } else if (li_r.size() > 1) {
		// listUtil lu = new listUtil();
		// String r = lu.orderByValueInt(li_r);
		// return r;
		// }

		li_r = orderType(li_r);
		TypeResult = li_r;
		return s;// "自身烦恼";
	}

	@SuppressWarnings("unchecked")
	static void getRenvasByKWnDweiuNKW2_test() {
		renvaEventC rec = new renvaEventC();
		rec.iniTypeKeywordLibFromDB();
		String s = "我们一起看日出，她说好,土豪金手机很好"; //
		fentsiController fc = new fentsiController();
		fc.iniFentsiWordlibFromdb();
		String fentsi = fc.fentsi(s);
		System.out.println(" fentsi:" + fentsi);
		String[] arr = fentsi.split(" ");
		List li = rec.getRenvasByKWnDweiuNKW2(arr, s);
		String r = JSONArray.fromObject(li).toString(2);
		System.out.println(r);

	}

	/**
	 * cbb
	 * 
	 * @param words
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Map> getRenvasByKWnDweiuNKW2(String[] words, String oriTxt) {
		List<String> li = li4readTypeWordLib;
		// aa
		String[] a = words;
		List li_r = new ArrayList();

		// by kweword
		for (Map.Entry<String, Set> entry : index4typeTsikuFile.entrySet()) {
			// System.out.println("key= " + entry.getKey() + " and value= " +
			// entry.getValue());
			Set typeStr = entry.getValue();

			int chwsyeNum = chwsyeNum(words, typeStr);

			// String setStr = JSONArray.fromObject(typeStr).toString();
			// System.out.println("-set:" + chwsyeNum + setStr);

			if (chwsyeNum > 0) {
				Map mp = new HashMap<String, Integer>();
				// msgTypeResult r=new msgTypeResult();
				// r.type= entry.getKey();
				// r.num=chwsyeNum;
				String type = entry.getKey();
				mp.put("name", type);
				mp.put("num", chwsyeNum);
				// listUtil.isContain(word,li);
				// li_r.add(mp);
				li_r.add(mp);
			}

		}

		// / by dweiu
		List<Map> renvasByKW = li_r;
		Set<String> renvas_set;
		// if(renvasByKW.size()>0)
		// {
		renvas_set = listUtil.toSet(renvasByKW, "name");
		dweiuMatchController dmc = new dweiuMatchController();
		List renvasByDweiu = dmc.getRenvas(oriTxt);
		List<String> lix = dmc.removeAllExistRenvas(renvasByDweiu, renvas_set);
		// if(!renvas_set.contains(renvasByDweiu_single))
		for (String renvasByDweiu_single : lix) {
			Map<String, String> mp = new HashMap<String, String>();
			mp.put("num", "0");
			mp.put("by", "dweiu");
			mp.put("name", renvasByDweiu_single);
			renvasByKW.add(mp);
			// return renvasByKW;
		}
		if (renvasByKW.size() > 0)
			return renvasByKW;
		// }
		// else
		// {
		// String renvasByDweiu_single=this.getRenva(oriTxt);
		// if(renvasByDweiu_single!=null)
		// {
		//			 
		// Map<String,String> mp=new HashMap<String, String>();
		// mp.put("num", "0");
		// mp.put("by", "dweiu");
		// mp.put("name", renvasByDweiu_single);
		// renvasByKW.add(mp);
		// return renvasByKW;
		// }
		//			 

		List<Map> renvasByKWnDweiu = renvasByKW;

		// by kw lev 2 二级关键词
		// renvasByKWnDweiu by kw_lev2
		if (renvasByKWnDweiu.size() == 0) {

			Map mp = getRenvaByKWlev2(words);
			if (mp != null) {
				renvasByKWnDweiu.add(mp);
				return renvasByKWnDweiu;
			}

		}

		// by defalult
		if (renvasByKWnDweiu.size() == 0) {
			msgTypeResult r = new msgTypeResult();
			r.type = "自身烦恼";
			r.num = 0;
			Map mp = new HashMap<String, Integer>();
			mp.put("name", "自身烦恼");
			mp.put("num", 0);
			li_r.add(mp);
		}
		// Gson gson = new Gson();
		// String reslut = gson.toJson(list);
		String s = "";// JSONArray.fromObject(li_r).toString();

		if (li_r.size() > 1)
			li_r = orderType(li_r);
		TypeResult = li_r;
		return li_r;// "自身烦恼";
	}

	private Map getRenvaByKWlev2(String[] words) {
		List<Map> li = new ArrayList<Map>();
		for (Map.Entry<String, Set> entry : KWlev2_map.entrySet()) {
			// System.out.println("key= " + entry.getKey() + " and value= " +
			// entry.getValue());
			Set typeStr = entry.getValue();

			int chwsyeNum = chwsyeNum(words, typeStr);

			// String setStr = JSONArray.fromObject(typeStr).toString();
			// System.out.println("-set:" + chwsyeNum + setStr);

			if (chwsyeNum > 0) {
				Map mp = new HashMap<String, Integer>();
				// msgTypeResult r=new msgTypeResult();
				// r.type= entry.getKey();
				// r.num=chwsyeNum;
				String type = entry.getKey();
				mp.put("name", type);
				mp.put("num", chwsyeNum);
				mp.put("by", "lev2");
				li.add(mp);
				// return (mp);
			}

		}
		if (li.size() > 0) {
			List<Map> li_ord = orderType(li);
			return li_ord.get(0);
		}
		return null;
	}

	/**
	 * 
	 * @param liR
	 * @return
	 */
	private List orderType(List liR) {
		List<Map> mappingList = null;
		Map<String, String> map = new TreeMap<String, String>();
		map.put("aaaa", "month");
		map.put("bbbb", "bread");
		map.put("ccccc", "attack");
		// map=mp;

		// 通过ArrayList构造函数把map.entrySet()转换成list
		// mappingList = new
		// ArrayList<Map.Entry<String,String>>(map.entrySet());
		mappingList = liR;
		// 通过比较器实现比较排序
		Collections.sort(mappingList, new Comparator<Map>() {
			public int compare(Map mapping1, Map mapping2) {

				Float int1 = Float.parseFloat(mapping1.get("num").toString());
				Float int2 = Float.parseFloat(mapping2.get("num").toString());
				if (int1 > int2)
					return -1;
				else if (int1 == int2)
					return 0;
				else
					return 1;
				// return mapping1.getValue().compareTo(mapping2.getValue());
			}
		});

		return mappingList;
	}

	private int chwsyeNum(String[] words, Set typeStr) {
		String[] a = words;
		int n = 0;
		Set set = typeStr;
		for (String word : a) {
			if (word.trim().equals(""))
				continue; // cbb
			// if(typeKeywords.contains(word))
			if (set.contains(word)) {
				n++;
				// System.out.println("-------------chwsyeNum:"+word);
			}
		}
		return n;
	}

	private void iniTypeKeywordLib(String typeWordLib) {
		listUtil lic = new listUtil();

		if (li4readTypeWordLib == null) {
			li4readTypeWordLib = lic.fileRead2listFiltEmptyLine(typeWordLib);

			index4typeTsikuFile = new HashMap<String, Set>();
			for (String typeStr : li4readTypeWordLib) {
				String[] ax = typeStr.split("\t");
				String type = ax[0];
				type = type.trim();
				type = strUtil.remove65279(type);
				String typeKeywords = ax[1];
				// String[] arr = typeKeywords.split(" ");
				Set set = listUtil.toSet(typeKeywords);
				index4typeTsikuFile.put(type, set);
			}
		}
	}

	public List renvaKws = new ArrayList<String>();;
	public List eventKws = new ArrayList<String>();

	@SuppressWarnings("unchecked")
	/**
	 * CREATE TABLE `word_renwu` (
  `id` varchar(255) NOT NULL DEFAULT '',
  `renwu` varchar(2550) DEFAULT NULL,
  `keyword` varchar(2550) DEFAULT NULL,
  `dweyu` varchar(2550) DEFAULT NULL,
  `secKW` varchar(2550) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
	 */
	public void iniTypeKeywordLibFromDB() {

		if (index4typeTsikuFile == null) {

			System.out.println("iniTypeKeywordLibFromDB ok");
			index4typeTsikuFile = new HashMap<String, Set>();
			map4renvaDweiu = new HashMap<String, List>(); // cb3
			KWlev2_map = new HashMap<String, Set>();
			//
			String sql = "SELECT * from word_renwu";
			// Dbcontroller dbc=this.dbc;
			ResultSet rs = dbc.getrs(sql);
			try {
				while (rs.next()) {

					// 首先使用ISO-8859-1字符集将name解码为字节序列并将结果存储新的字节数组中。
					// 然后使用GB2312字符集解码指定的字节数组
					// name = new String(name.getBytes("ISO-8859-1"),"GB2312");

					// 输出结果
					String txt = rs.getString("renwu");
					Set set = listUtil.toSet(rs.getString("keyword"));
					if (set != null)
						renvaKws.addAll(set);
					index4typeTsikuFile.put(txt, set);

					// cb3
					String dweiuItems = rs.getString("dweyu");
					if (dweiuItems != null)// cb9
						if (dweiuItems.trim().length() > 0)
							map4renvaDweiu.put(txt, listUtil.toList(
									dweiuItems, " "));

					// cbb
					String 二级关键词 = rs.getString("secKW");
					if (二级关键词 != null && 二级关键词.trim().length() > 0)

						KWlev2_map.put(txt, listUtil.toSet(二级关键词, " "));

				}
			} catch (SQLException e) {
				e.printStackTrace();
				throw new RuntimeException(e);
			}
		}

	}

	private static Map cacheSourceLineAndWordArray(List<String> li) {
		// cache source file lines
		Map map2 = new HashMap();
		if (fileLineMap == null) {

			for (String line : li) {
				String[] a = strUtil.splitx(line, "\\|");//
				List<String> li1 = new ArrayList<String>();
				for (String word : a) {
					li1.add(word);
				}

				String[] arrWord = li1.toArray(new String[li1.size()]);
				map2.put(line, arrWord);
			}
			fileLineMap = map2;
		}
		return map2;
	}

	private List<String[]> cacheSourceLineAndWordArrayX(List<String> li) {
		// cache source file lines
		List<String[]> li_r = new ArrayList<String[]>();
		// Map map2 = new HashMap();
		if (li4readSource == null) {

			for (String line : li) {
				String[] a = strUtil.splitx(line, "\\|");//

				li_r.add(a);
			}
			li4readSource = li_r;
		}
		return li_r;
	}

	private String getEvent(String str, String file) {
		List<String> li_r = getEventList(str, file);
		if (li_r.size() == 0)
			return "其他";

		return listUtil.toString(li_r, " | ");
	}

	List<String[]> li4readSource;
	Map<String, String> EventListmp;
	public static List<String> li4readEventWordLib;
	Map EventListOnlyKeyword;

	/**
	 * 
	 * @param str
	 * @param file
	 * @return [0010001_恋爱男女_追求,3 ||| 0100004_自身烦恼_恋爱,3]
	 */
	private List<String> getEventList(String str, String file) {
		listUtil lic = new listUtil();

		if (li4readEventWordLib == null)
			li4readEventWordLib = lic.fileRead2list(file, "gbk");
		List<String> li = li4readEventWordLib;

		//	

		// cache EventList table
		if (EventListmp == null) {
			EventListmp = new HashMap<String, String>();
			EventListOnlyKeyword = new HashMap<String, Object>();
			for (String typeStr : li) {
				if (typeStr.trim().length() == 0)
					continue;
				// String[] ax=typeStr.split("\t");// 10%
				String[] ax = strUtil.splitx(typeStr, "\t");
				String type = ax[0] + "_" + ax[1] + "_" + ax[2];
				String typeKeywords = ax[3];
				EventListmp.put(typeStr + "_event", type);
				EventListmp.put(typeStr + "_eventWord", typeKeywords);

				Set set = listUtil.toSet(typeKeywords);
				EventListOnlyKeyword.put(typeKeywords, set);
			}
		}

		List<String> li_r = new ArrayList<String>();

		// System.out.println(" --caj1");
		// t1.printUseTime();
		// if(true)return li_r;
		int n = 0;
		for (String typeStr : li) {
			n++;
			if (n == 1)
				continue;
			if (typeStr.trim().length() == 0)
				continue;
			// String[] ax=typeStr.split("\t");// 10%
			// String[] ax=strUtil.splitx(typeStr, "\t");
			// String type=ax[0]+"_"+ax[1]+"_"+ax[2];
			// String typeKeywords=ax[3];

			String type = EventListmp.get(typeStr + "_event");
			String typeKeywords = EventListmp.get(typeStr + "_eventWord");

			int chwsyeNum = strUtil.chwsyeNum(str, typeKeywords,
					EventListOnlyKeyword, fileLineMap); // %54
			if (chwsyeNum > 0) {
				String s = type + "," + String.valueOf(chwsyeNum);
				li_r.add(s);
			}

		}
		return li_r;
	}

	/**
	 * @since ca21
	 * @param str
	 * @param file
	 * @return
	 */
	private List getEvents(String[] str, String type, String file) {

		iniEventKeywordlib(file);

		// if (true)
		// return null;

		List li_r = new ArrayList();

		Map<String, Set> lineses = (Map) mp4typeAndEventfileLinesetX.get(type);
		for (Map.Entry<String, Set> entry : lineses.entrySet()) {
			// System.out.println("key= " + entry.getKey() + " and value= " +
			// entry.getValue());

			Set set = entry.getValue();
			int chwsyeNum = chwsyeNum(str, set); // %54
			if (chwsyeNum > 0) {
				Map mp = new HashMap<String, Object>();
				mp.put("num", chwsyeNum);
				mp.put("event", entry.getKey());
				li_r.add(mp);
			}

		}

		return li_r;
	}

	Map mp4typeAndEventfileLineset;

	/**
	 * @author attilax 1466619819@qq.com
	 * @param str
	 * @param type
	 * @param eventwordlib
	 * @return
	 */
	@SuppressWarnings("unchecked")
	private List<String> getEventList(String str, String typeShortformat,
			String eventwordlib) {
		iniEventKeywordlib(eventwordlib);

		List<String> li_r = new ArrayList<String>();

		// System.out.println(" --caj1");
		// t1.printUseTime();
		// if(true)return li_r;
		int n = 0;
		// for (String typeStr : li) {

		// byte[] b=typeShortformat.getBytes();
		// char[] c=typeShortformat.toCharArray();
		List<String> list4typeLineset = (List) mp4typeAndEventfileLineset
				.get(typeShortformat);
		// System.out.println("--cak:type"+typeShortformat);
		// char c1=c[0];
		// int c1num=c1;
		for (String typeStr : list4typeLineset) {
			n++;
			if (n == 1)
				continue;
			if (typeStr.trim().length() == 0)
				continue;
			// String[] ax=typeStr.split("\t");// 10%
			// String[] ax=strUtil.splitx(typeStr, "\t");
			// String type=ax[0]+"_"+ax[1]+"_"+ax[2];
			// String typeKeywords=ax[3];

			String type = EventListmp.get(typeStr + "_event");
			String typeKeywords = EventListmp.get(typeStr + "_eventWord");

			int chwsyeNum = strUtil.chwsyeNum(str, typeKeywords,
					EventListOnlyKeyword, fileLineMap); // %54
			if (chwsyeNum > 0) {
				String s = type + "," + String.valueOf(chwsyeNum);
				li_r.add(s);
			}

		}
		return li_r;
	}

	@SuppressWarnings("unchecked")
	private List<String> getEventList(String[] str, String typeShortformat,
			String eventwordlib) {
		iniEventKeywordlib(eventwordlib);

		List<String> li_r = new ArrayList<String>();

		// System.out.println(" --caj1");
		// t1.printUseTime();
		// if(true)return li_r;
		int n = 0;
		// for (String typeStr : li) {

		// byte[] b=typeShortformat.getBytes();
		// char[] c=typeShortformat.toCharArray();
		List<String> list4typeLineset = (List) mp4typeAndEventfileLineset
				.get(typeShortformat);
		// System.out.println("--cak:type"+typeShortformat);
		// char c1=c[0];
		// int c1num=c1;
		for (String typeStr : list4typeLineset) {
			n++;
			if (n == 1)
				continue;
			if (typeStr.trim().length() == 0)
				continue;
			// String[] ax=typeStr.split("\t");// 10%
			// String[] ax=strUtil.splitx(typeStr, "\t");
			// String type=ax[0]+"_"+ax[1]+"_"+ax[2];
			// String typeKeywords=ax[3];

			String type = EventListmp.get(typeStr + "_event");
			String typeKeywords = EventListmp.get(typeStr + "_eventWord");

			// int chwsyeNum = strUtil.chwsyeNum(str, typeKeywords,
			// EventListOnlyKeyword, fileLineMap); // %54
			// if (chwsyeNum > 0) {
			// String s = type + "," + String.valueOf(chwsyeNum);
			// li_r.add(s);
			// }

		}
		return li_r;
	}

	Map mp4typeAndEventfileLinesetX;

	private void iniEventKeywordlib(String eventwordlib) {
		listUtil lic = new listUtil();

		if (li4readEventWordLib == null)
			li4readEventWordLib = lic.fileRead2list(eventwordlib, "gbk");
		List<String> li = li4readEventWordLib;

		//	

		// cache EventList table
		if (EventListmp == null) {
			mp4typeAndEventfileLineset = new HashMap<String, List>();
			EventListmp = new HashMap<String, String>();
			EventListOnlyKeyword = new HashMap<String, Object>();
			mp4typeAndEventfileLinesetX = new HashMap<String, Map>();
			for (String typeStr : li) {
				if (typeStr.trim().length() == 0)
					continue;
				// String[] ax=typeStr.split("\t");// 10%
				String[] ax = strUtil.splitx(typeStr, "\t");
				String type = ax[0] + "_" + ax[1] + "_" + ax[2];
				String typeKeywords = ax[3];
				EventListmp.put(typeStr + "_event", type);
				EventListmp.put(typeStr + "_eventWord", typeKeywords);

				Set set = listUtil.toSet(typeKeywords);
				EventListOnlyKeyword.put(typeKeywords, set);

				// cak
				String typeTypeformat = ax[1];
				List Lineset = (List) mp4typeAndEventfileLineset
						.get(typeTypeformat);
				if (Lineset == null) {
					Lineset = new ArrayList<String>();
				}
				Lineset.add(typeStr);
				mp4typeAndEventfileLineset.put(typeTypeformat, Lineset);

				// cak pm
				Map listset2 = (Map) mp4typeAndEventfileLinesetX
						.get(typeTypeformat);
				if (listset2 == null) {
					listset2 = new HashMap<String, Set>();
				}
				Set setx = listUtil.toSet(typeKeywords);
				listset2.put(type, setx);
				mp4typeAndEventfileLinesetX.put(typeTypeformat, listset2);
			}
		}
	}

	List<String> li4readTypeWordLib;

	public String getType(String str, String file) {

		String[] acak = str.split("\\|");
		if (true)
			return getType(acak, file);
		listUtil lic = new listUtil();

		if (li4readTypeWordLib == null)
			li4readTypeWordLib = lic.fileRead2list(file);
		List<String> li = li4readTypeWordLib;

		String[] a = str.split("\\|");
		List<Map<String, Integer>> li_r = new ArrayList<Map<String, Integer>>();
		for (String typeStr : li) {
			String[] ax = typeStr.split("\t");
			String type = ax[0];
			type = type.trim();
			type = strUtil.remove65279(type);
			String typeKeywords = ax[1];
			int chwsyeNum = strUtil.chwsyeNum(str, typeKeywords);
			if (chwsyeNum > 0) {
				Map mp = new HashMap<String, Integer>();
				mp.put(type, chwsyeNum);
				// listUtil.isContain(word,li);
				li_r.add(mp);
			}

		}

		if (li_r.size() == 1) {
			Map mpx = li_r.get(0);

			// Set set= mpx.keySet();
			Set<String> set = mpx.keySet();
			Iterator<String> it = set.iterator();
			while (it.hasNext()) {
				String strx = it.next();
				return strx;
			}

		} else if (li_r.size() > 1) {
			listUtil lu = new listUtil();
			String r = lu.orderByValueInt(li_r);
			return r;
		}
		return "自身烦恼";

	}

	public String getType(String[] str_arr) {

		String file = "C:\\renvaEvent\\renvagwesyi.txt";

		String[] acak = str_arr;
		if (true)
			return getType(acak, file);
		return "";
	}

	public String getTypeFromDB(String[] keywArr) {

		// iniTypeKeywordLibFromDB();

		return getTypeCa25(keywArr);

	}

	public static void getTypeFromDB_test() {

		// iniTypeKeywordLibFromDB();
		String[] keywArr = new String[] { "男朋友" };
		fulltxtControllor.ini_fentsiController();
		renvaEventC rec = new renvaEventC();
		rec.getTypeCa25(keywArr);
		String s = JSONArray.fromObject(rec.TypeResult).toString();
		System.out.println("=====" + s);

	}

	/**
	 * feicyi
	 * 
	 * @param keywArr
	 * @return
	 */
	public String getRenvaByKwNDweiu(String[] keywArr) {

		iniTypeKeywordLibFromDB();

		return getTypeCa25(keywArr);

	}

	/**
	 * getEvents By Kw N Dweiu
	 * 
	 * @param keywArr
	 * @param renvaList
	 * @return
	 */
	public List getEventsFromDBlib(String[] keywArr, List<Map> renvaList) {

		iniEventKeywordlibFromdb();
		return getEvents(keywArr, renvaList);

	}

	/**
	 * "eventOnly",list(dweiiu list)
	 * 
	 * @since cb3
	 * 
	 */
	public static Map<String, List> map4eventDweiu;

	public void iniEventKeywordlibFromdb() {

		// cb5
		if (li4readEventWordLib != null)
			return;
		// /cb5

		listUtil lic = new listUtil();

		if (li4readEventWordLib == null)
			// li4readEventWordLib = lic.fileRead2list(eventwordlib, "gbk");
			li4readEventWordLib = getEventsFromDbCb3();
		List<String> li = li4readEventWordLib;

		//	

		// cache EventList table
		if (EventListmp == null) {
			mp4typeAndEventfileLineset = new HashMap<String, List>();
			EventListmp = new HashMap<String, String>();
			EventListOnlyKeyword = new HashMap<String, Object>();
			mp4typeAndEventfileLinesetX = new HashMap<String, Map>();
			// map4renvaDweiu=new HashMap<String, List>();
			for (String typeStr : li) {
				if (typeStr.trim().length() == 0)
					continue;
				// String[] ax=typeStr.split("\t");// 10%
				String[] ax = strUtil.splitx(typeStr, "\t");
				String type = ax[0] + "_" + ax[1] + "_" + ax[2];
				String typeKeywords = ax[3];
				EventListmp.put(typeStr + "_event", type);
				EventListmp.put(typeStr + "_eventWord", typeKeywords);

				Set set = listUtil.toSet(typeKeywords);
				EventListOnlyKeyword.put(typeKeywords, set);

				// cak
				String typeTypeformat = ax[1];
				List Lineset = (List) mp4typeAndEventfileLineset
						.get(typeTypeformat);
				if (Lineset == null) {
					Lineset = new ArrayList<String>();
				}
				Lineset.add(typeStr);
				mp4typeAndEventfileLineset.put(typeTypeformat, Lineset);

				// cak pm
				Map listset2 = (Map) mp4typeAndEventfileLinesetX
						.get(typeTypeformat);
				if (listset2 == null) {
					listset2 = new HashMap<String, Set>();
				}
				Set setx = listUtil.toSet(typeKeywords);
				listset2.put(type, setx);
				mp4typeAndEventfileLinesetX.put(typeTypeformat, listset2);

				// cb5
				// mp4event_key_is_ByaohaoAndEventname_value_is_keywordSet.put
			}
		}

	}
/**
 * zafei
 * CREATE TABLE `word_event` (
  `id` varchar(255) DEFAULT NULL,
  `name` varchar(2550) DEFAULT NULL,
  `keyword` varchar(2550) DEFAULT NULL,
  `dweyu` varchar(2550) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
zafei
 * @return
 */
	private List<String> readFromdbAndConvetformta() {
		List<String> li = new ArrayList<String>();
		String sql = "SELECT * from 事件关系分类表";
		Dbcontroller c = new DbNdsController();
		ResultSet rs = c.getrs(sql);
		try {
			while (rs.next()) {

				// 首先使用ISO-8859-1字符集将name解码为字节序列并将结果存储新的字节数组中。
				// 然后使用GB2312字符集解码指定的字节数组
				// name = new String(name.getBytes("ISO-8859-1"),"GB2312");

				// 输出结果
				String byaohao = rs.getString("编号");
				String relation = rs.getString("所属关系类");
				String name = rs.getString("名称");
				String kw = rs.getString("关键字");
				String s = byaohao + "\t" + relation + "\t" + name + "\t" + kw;

				li.add(s);

			}
		} catch (SQLException e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}
		c.close();
		return li;
	}

	public static Map map4eventByaohaoComparetable;
	List<Map> list4event;// cb5

	/**
	 * CREATE TABLE `word_event` (
  `id` varchar(255) DEFAULT NULL,
  `name` varchar(2550) DEFAULT NULL,
  `keyword` varchar(2550) DEFAULT NULL,
  `dweyu` varchar(2550) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

	 * @author Administrator
	 * @return
	 */
	private List<String> getEventsFromDbCb3() {
		if (map4eventDweiu != null) {
			return null;
		}
		if (map4eventDweiu == null) {
			map4eventDweiu = new HashMap<String, List>();// cb3
			map4eventByaohaoComparetable = new HashMap<String, List>();// cb5
			list4event = new ArrayList<Map>();
			mp4event_key_is_ByaohaoAndEventname_value_is_keywordSet = new HashMap<String, Set>();
		}
		List<String> li = new ArrayList<String>();
		String sql = "SELECT * from word_event";
		Dbcontroller dbc = this.dbc;
		ResultSet rs = dbc.getrs(sql);
		try {
			while (rs.next()) {

				// 首先使用ISO-8859-1字符集将name解码为字节序列并将结果存储新的字节数组中。
				// 然后使用GB2312字符集解码指定的字节数组
				// name = new String(name.getBytes("ISO-8859-1"),"GB2312");

				// 输出结果
				String byaohao = rs.getString("id");
				// String relation = rs.getString("所属关系类");
				String name = rs.getString("name");
				String kw = rs.getString("keyword");
				String s = byaohao + "\t@relation\t" + name + "\t" + kw;

				li.add(s);
				map4eventByaohaoComparetable.put(name, byaohao);

				map4eventDweiu.put(name, strUtil.toList(rs.getString("dweyu"),
						" "));
				// cb5
				Map<String, String> mp = new HashMap<String, String>();
				// mp.put(name, value)

				Set set = listUtil.toSet(kw);
				if (set != null)
					eventKws.addAll(set);
				String byehao_event = byaohao + "_" + name;
				mp4event_key_is_ByaohaoAndEventname_value_is_keywordSet.put(
						byehao_event, set);

			}
		} catch (SQLException e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}

		List li_cb3 = new ArrayList<String>();
		iniTypeKeywordLibFromDB();
		Map mp4renva = index4typeTsikuFile;
		Set<String> key = mp4renva.keySet();
		for (Iterator it = key.iterator(); it.hasNext();) {
			String renva = (String) it.next();
			for (String event_notok : li) {
				String event = event_notok.replaceAll("@relation", renva);
				li_cb3.add(event);
			}
			// System.out.println(map.get(s));
		}

		// append 自身烦恼
		String renvax = "自身烦恼";
		for (String event_notok : li) {
			String event = event_notok.replaceAll("@relation", renvax);
			li_cb3.add(event);
		}

		return li_cb3;
	}

	public static Map map4renvaDweiu;
	public String oritxt;

	public List<Map> geneRenvaList4problemlib(String renvaids, Map mpx) {
		List<Map> li = new ArrayList<Map>();
		List<Map> renvaLI = geneRenvaList(renvaids);
		for (int i = 0; i < renvaLI.size(); i++) {
			Map mp = renvaLI.get(i);
			// Map mp=renvaLI.get(0);
			String renva = (String) mp.get("name");
			if (renva.equals("自身烦恼")) {
				String s = (String) mpx.get("content");
				String renvax = getRenva(s);
				System.out.println("");
				if (renvax != null) {
					mp.put("name", renvax);
					// mp.put("namex", renva);
				}

			}
			li.add(mp);

		}

		return li;
		// return null;
	}

	/**
	 * getRenva Single by dweiu
	 * 
	 * @param s
	 * @return
	 */
	private String getRenva(String s) {

		Set<String> key = map4renvaDweiu.keySet();
		for (Iterator it = key.iterator(); it.hasNext();) {
			String renva_key = (String) it.next();
			;
			List<String> dweius = (List) map4renvaDweiu.get(renva_key);
			for (String dweiu : dweius) {
				boolean rs = strUtil.isFind(s, dweiu);
				if (rs) {
					// System.out.println("renva_key:"+renva_key);
					return renva_key;
				}
			}
		}

		return null;
	}

	// private boolean isFind(String s, String dweiu) {
	// String regEx = dweiu.replaceAll("\\*", ".{0,7}?"); //表示a或F
	// // System.out.println("\r\n"+regEx);
	// Pattern pat = Pattern.compile(regEx);
	// Matcher mat = pat.matcher(s);
	// boolean rs = mat.find();
	// return rs;
	// }

	public List getEventsFromDBlib(String[] txtFentsiedArray,
			List<Map> renvaList, String txtLine) {
		iniEventKeywordlibFromdb();
		return getEvents_AndByDweiu(txtFentsiedArray, renvaList, txtLine);
	}

	/**
	 * 
	 * @param keywArr
	 * @param str
	 * @return
	 */
	public List<Map> getRenvaByKwNDweiu(String[] keywArr, String str) {
		iniTypeKeywordLibFromDB();
		getTypeCa25(keywArr);
		List<Map> renvasByKW = this.TypeResult;
		Set<String> set = listUtil.toSet(renvasByKW, "name");

		String renvasByDweiu_single = this.getRenva(str);
		if (set.contains(renvasByDweiu_single))
			return renvasByKW;
		else {
			Map<String, String> mp = new HashMap<String, String>();
			mp.put("num", "0");
			mp.put("by", "dweiu");
			mp.put("name", renvasByDweiu_single);
			renvasByKW.add(mp);
			return renvasByKW;
		}

		// return null;
	}

}
